/**
 * 
 */
package ccrClasses.layer2;

import ccrClasses.ICcr;

/**
 * A unique industry standard code is needed for each entry so that different systems can agree
 *  on how to differentiate between, for example, Diabetes and Measles. There is also the option
 *   to provide a text representation of the code, such as "Diabetes." There are many different 
 *   coding systems in use by the medical community. Our plan is to support at least one of the 
 *   existing coding systems for each category of medical information (medications, conditions, etc.)
 * @author matheus
 *
 */
public class Code implements ICcr{
	
	public static String OPEN_TAG = "<Code>";

	public static String CLOSE_TAG = "</Code>";
	
	private Value value;
	
	private CodingSystem codingSystem;
	
	private Version version;

	public Code(Value value, CodingSystem codingSystem, Version version) {
		super();
		this.value = value;
		this.codingSystem = codingSystem;
		this.version = version;
	}

	public Code() {
		super();
	}

	/**
	 * @return the value
	 */
	public Value getValue() {
		return value;
	}

	/**
	 * @param value the value to set
	 */
	public void setValue(Value value) {
		this.value = value;
	}

	/**
	 * @return the codingSystem
	 */
	public CodingSystem getCodingSystem() {
		return codingSystem;
	}

	/**
	 * @param codingSystem the codingSystem to set
	 */
	public void setCodingSystem(CodingSystem codingSystem) {
		this.codingSystem = codingSystem;
	}

	/**
	 * @return the version
	 */
	public Version getVersion() {
		return version;
	}

	/**
	 * @param version the version to set
	 */
	public void setVersion(Version version) {
		this.version = version;
	}

	/**
	 * @return the oPEN_TAG
	 */
	public String getOPEN_TAG() {
		return OPEN_TAG;
	}

	/**
	 * @return the cLOSE_TAG
	 */
	public String getCLOSE_TAG() {
		return CLOSE_TAG;
	}

	@Override
	public String constructCcrString() {
		String ccrCode = OPEN_TAG;
		
		if(value != null){
			ccrCode = ccrCode + value.constructCcrString();
		}
		
		if(codingSystem != null){
			ccrCode = ccrCode + codingSystem.constructCcrString();
		}
		
		ccrCode = ccrCode + Version.VALUE;
		ccrCode = ccrCode + CLOSE_TAG;
		return ccrCode;
	}
	
	

}
